<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<script type="text/javascript">
function toCreate(){
	window.location.href = ctx + '/admin/cases/scenario/create.do?casesId=' + $("#casesId").val();
}
function toUpdate(){
	var array = [];
	array['casesId'] = $("#casesId").val();
	var url = "<c:url value='/admin/cases/scenario/update.do' />";
	sns.toUpdate(url, array, 'ck_scenarios','scenarioId');
}
function toDelete(){
	var array = [];
	array['casesId'] = $("#casesId").val();
	var url = "<c:url value='/admin/cases/scenario/delete.do' />";
	sns.toRemove(url, array, 'ck_scenarios','scenarioId');
}
function manageScenario(){
	var selectedCasesId = sns.getCheckbox('ck_scenarios');
	if(selectedCasesId == false){
		alert('please choose at least one');
		return;
	}
	if(selectedCasesId.indexOf(",") != -1){
		alert('Only can choose one');
		return;
	}
	location.href= ctx + '/admin/cases/scenario/manager.do?scenarioId='+selectedCasesId;
}
</script>
<div class="bu">
<button onclick="toCreate()" class="btn3_mouseout" onmouseover="this.className='btn3_mouseover'"
onmouseout="this.className='btn3_mouseout'" onmousedown="this.className='btn3_mousedown'"
onmouseup="this.className='btn3_mouseup'" title="Create"><fmt:message key="common.create"/></button>&nbsp;&nbsp;
<button onclick="toUpdate()" class="btn3_mouseout" onmouseover="this.className='btn3_mouseover'"
onmouseout="this.className='btn3_mouseout'" onmousedown="this.className='btn3_mousedown'"
onmouseup="this.className='btn3_mouseup'"title="UPDATE"><fmt:message key="common.update"/></button>&nbsp;&nbsp;
<button onclick="toDelete()" class="btn3_mouseout" onmouseover="this.className='btn3_mouseover'"
onmouseout="this.className='btn3_mouseout'" onmousedown="this.className='btn3_mousedown'"
onmouseup="this.className='btn3_mouseup'"title="UPDATE">删除</button>&nbsp;&nbsp;
<button onclick="manageScenario()" class="btn3_mouseout" onmouseover="this.className='btn3_mouseover'"
onmouseout="this.className='btn3_mouseout'" onmousedown="this.className='btn3_mousedown'"
onmouseup="this.className='btn3_mouseup'"title="UPDATE">动作/对象管理</button>
</div>
<div>
<input type="hidden" id="casesId" name="casesId" value="${casesId}">
<table id="t_cases_list" width="100%"  border="0" cellpadding="0" cellspacing="0" class="pub_list01">
	<thead>
		<tr>
			<th width="50px" class="tdCenter">
			</th>
			<th width="75px" class="tdCenter">编码</th>
			<th width="75px" class="tdCenter">场景标题</th>
			<th width="75px" class="tdCenter">场景的位置</th>
			<th width="75px" class="tdCenter">是否是正确的结束</th>
			<th width="75px" class="tdCenter">可用</th>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="scenario" items="${page.items}" varStatus="status">
		<tr>
			<td class="tdCenter">
				<input type="checkbox" name="ck_scenarios" id="ck_<c:out value='${scenario.scenarioId}' />" value="${scenario.scenarioId}"></input>
			</td>
			<td class="tdCenter">
				<c:out value="${scenario.scenarioCode}"></c:out>
			</td>
			<td class="tdCenter">
				<c:out value="${scenario.title}"></c:out>
			</td>
			<td class="tdCenter">
				<c:if test="${scenario.position == 1}">
					开始
				</c:if>
				<c:if test="${scenario.position == -1}">
					结束
				</c:if>
				<c:if test="${scenario.position != 1 && scenario.position != -1}">
					中间
				</c:if>
			</td>
			<td class="tdCenter">
				<c:if test="${scenario.answer == 1}">
					正确
				</c:if>
				<c:if test="${scenario.answer == -1}">
					错误
				</c:if>
				<c:if test="${scenario.answer != 1 && scenario.answer != -1}">
					没有结束
				</c:if>
			</td>
			<td class="tdCenter">
				<c:if test="${scenario.enabled == -1}">
					<fmt:message key="common.notenabled"/>
				</c:if>
				<c:if test="${scenario.enabled == 1}">
					<fmt:message key="common.enabled"/>
				</c:if>
			</td>
		</tr>
		</c:forEach>
	</tbody>
</table>
<jsp:include page="/common/pager.jsp" />
</div>
<br/>